home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / PowerD / alpha / examples / Watch.d < prev    next >
Encoding:
Text File  |  2002-10-28  |  932 b   |  31 lines

  1.  
  2. OPT OSVERSION=37
  3.  
  4. MODULE 'dos/notify'
  5.  
  6. PROC main()(INT)                       /* make sure file is there: else we'll */
  7.   DEF nreq:PTR TO NotifyRequest,sig,task
  8.   IF (FileLength(arg)=-1) OR (arg[0]=0)     /* never be notified */
  9.     PrintF('file "\s" does not exist\n',arg)
  10.     Exit(10)
  11.   ENDIF
  12.   nreq:=New(SIZEOF_NotifyRequest)     /* memory is cleared */
  13.   IF nreq=NIL THEN RETURN 20
  14.   sig:=AllocSignal(-1)                /* we want to be signalled */
  15.   IF sig=-1 THEN RETURN 10
  16.   task:=FindTask(0)
  17.   nreq.Name:=arg                      /* fill in structure */
  18.   nreq.Flags:=NRF_SEND_SIGNAL
  19.   nreq.Port:=task                     /* union port/task */
  20.   nreq.SignalNum:=sig
  21.   IF StartNotify(nreq)
  22.     PrintF('Now watching: "\s"\n',arg)
  23.     Wait(Shl(1,sig))
  24.     EasyRequestArgs(0,[20,0,0,'File "\s" modified!','Damn!'],0,[arg])
  25.     EndNotify(nreq)
  26.   ELSE
  27.     PrintF('Could not watch "\s".\n',arg)
  28.   ENDIF
  29.   FreeSignal(sig)
  30. ENDPROC
  31.